package cn.class2.demo7

/**
  * Created by lzd on 2018/11/15.
  * option\some\none
  */
object Demo1 {
  def main(args: Array[String]): Unit = {
    val map = Map("a" -> 1, "b" -> 2, "c" -> "hello")
    println(map.getOrElse("a", -2))
    println(map.getOrElse("f", -2))

    /** option 包装器 ，只有两个对象，一个some代表有值，一个none代表没值 */

    val vals: Option[Any] = map.get("e")
    vals match {
      case Some(vals) => println(vals)
      case None => println("bye")
    }
  }
}
